<?php
	   session_start();
	   $route_id = (int)$_GET['route_id'];
	   $journey = $_GET['journey'];
	   $route = $_GET['route'];
	   if(!isset($_GET['route'])){
			echo $_SESSION[$journey]['route']; 
			exit;
		}

		// If the route_id is 0, that means the route is being created
		if($route_id==0){
				//mysql_query("INSERT INTO journeys (journeyname, route) VALUES('".$journey."','".$route."')");
				$_SESSION[$journey]['route'] = $route;

				// We have to print the new route_id for further updation
				echo 3;
				//echo mysql_insert_id();
				exit();
		}
		// If the route_id is not 0, that means the route is being edited.
		else{
				//mysql_query("UPDATE journeys SET journeyname='".$journey."', route='".$route."' WHERE route_id=".$route_id);
				//echo mysql_insert_id();
				$_SESSION[$journey]['route'] = $route;

				// We have to print the new route_id for further updation
				echo 3;
				//echo mysql_insert_id();
				exit();
		}
?>